import React from 'react'
import {  Table} from 'antd'

export default function ArticlePublish(props) {

    const columns = [
        {
            title: '文章标题',
            dataIndex: 'title',
            render: (title,item) => {
                return <a href={`#/news-manage/preview/${item.pageId}`}>{title}</a>
            }
        },
        {
            title: '作者',
            dataIndex: 'author'
        },
        {
            title: "文章分类",
            dataIndex: 'categoryName',
            render: (categoryName) => {
                return <div>{categoryName}</div>
            }
        },
        {
            title: "操作",
            render: (item) => {
                return <div>
                    {props.button(item.pageId)}
                </div>
            }
        }
    ];
    // 翻页器回调
    const handlePageChange = (page, pageSize) => { 
        props.changePage(page, pageSize)
    }
    return (
        <div>
            <Table dataSource={props.dataSource} columns={columns}
                pagination={{
                    total: props.total,
                    onChange: (page, pageSize) => handlePageChange(page, pageSize), //改变页码的函数
                    showSizeChanger: true,
                    showQuickJumper: false,
                }}
                rowKey={item=>item.pageId}
            />
        </div>
    )
}
